<?php
/**
 * Created by PhpStorm.
 * User: liujun
 * Date: 2018/8/10
 * Time: 下午1:22
 */

namespace PddWechat\Models\Mall\Service;


use Dai\Framework\Base\BaseSessionInfo;
use PddWechat\Models\User\Data\UserPromotionUrlData;

class RedPack
{
    /**
     * @param $basePageInfo
     */
    public function execute($basePageInfo) {
        /** @var BaseSessionInfo $sessionData */
        $sessionData = $basePageInfo->sessionInfo;
        $openid = $sessionData->openId;

        $userPromotionUrlData = new UserPromotionUrlData();
        $userPromotionUrlDo = $userPromotionUrlData->getUserByOpenId($openid);
        $url = $userPromotionUrlDo->redPackUrl;
        header("Location: $url");
        exit;
    }
}